package com.pda.gongpin.ui.fulltrayin;

import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.fragment.app.FragmentManager;

import com.pda.gongpin.R;
import com.pda.gongpin.bean.SkuListBean;
import com.pda.gongpin.contract.FullTrayInNewContract;
import com.pda.gongpin.presenter.FullTrayInNewPresenter;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

import butterknife.BindView;

public class FullTrayInNewFragment extends BaseMvpFragment<FullTrayInNewPresenter> implements FullTrayInNewContract.View {
    @BindView(R.id.tv_yuan_1)
    TextView tvYuan1;
    @BindView(R.id.tv_title1)
    TextView tvTitle1;
    @BindView(R.id.view1)
    View view1;
    @BindView(R.id.tv_yuan_2)
    TextView tvYuan2;
    @BindView(R.id.tv_title2)
    TextView tvTitle2;
    @BindView(R.id.view2)
    View view2;
    @BindView(R.id.tv_yuan_3)
    TextView tvYuan3;
    @BindView(R.id.tv_title3)
    TextView tvTitle3;
    @BindView(R.id.tv_deliveryNo)
    TextView tvDeliveryNo;
    @BindView(R.id.flContent)
    FrameLayout flContent;
    FragmentManager fragmentManager;
    private String entryNo,erpCode;

    public FullTrayInNewFragment(String entryNo, String erpCode) {
        this.entryNo = entryNo;
        this.erpCode = erpCode;
    }

    public FullTrayInNewFragment() {
    }

    @Override
    public FullTrayInNewPresenter getPresenter() {
        return new FullTrayInNewPresenter();
    }

    @Override
    public int getViewId() {
        return R.layout.fragment_full_tray_in_new;
    }
    @Subscribe
    public void onEvent(SkuListBean skuListBean){
        if (!TextUtils.isEmpty(skuListBean.getNum())){
            tvYuan2.setBackgroundResource(R.mipmap.icon_full_in);
            tvYuan3.setBackgroundResource(R.drawable.bg_3f7bfa_180);
            tvYuan3.setTextColor(getActivity().getResources().getColor(R.color.white));
            tvTitle3.setTextColor(getActivity().getResources().getColor(R.color._3F7BFA));
            tvYuan2.setText("");
            skuListBean.setEntryNo(entryNo);
            view2.setBackgroundColor(getActivity().getResources().getColor(R.color._3F7BFA));
            fragmentManager.beginTransaction().replace(R.id.flContent,new FullTrayInThreeFragment(skuListBean)).commit();
        }else {
            view1.setBackgroundColor(getActivity().getResources().getColor(R.color._3F7BFA));
            tvTitle2.setTextColor(getActivity().getResources().getColor(R.color._3F7BFA));
            tvYuan2.setBackgroundResource(R.drawable.bg_3f7bfa_180);
            tvYuan2.setTextColor(getActivity().getResources().getColor(R.color.white));
            tvYuan1.setBackgroundResource(R.mipmap.icon_full_in);
            tvYuan1.setText("");
            fragmentManager.beginTransaction().replace(R.id.flContent,new FullTrayInTwoFragment(skuListBean)).commit();
        }
    }
    @Override
    public void initView() {
        EventBus.getDefault().register(this);
        tvDeliveryNo.setText("入库单信息 "+erpCode);
        fragmentManager=getChildFragmentManager();
        fragmentManager.beginTransaction().add(R.id.flContent,new FullTrayInOneFragment(entryNo)).commit();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

    }

    @Override
    public void setList(List<SkuListBean> list) {

    }
}
